package com.jsoft.webservice;

import com.jsoft.dto.MenuDto;
import com.jsoft.dto.OrderItemDto;
import com.jsoft.dto.SectorDto;
import com.jsoft.dto.UserDto;
import com.jsoft.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.context.support.SpringBeanAutowiringSupport;

import javax.jws.WebService;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * Date: 15.08.13
 * Time: 23:03
 */

@WebService
public class AuthenticationWebServiceImpl extends SpringBeanAutowiringSupport implements AuthenticationWebService {
    @Autowired
    private UserService userService;
    @Autowired
    private RecipeService recipeService;
    @Autowired
    private OrderService orderService;
    @Autowired
    private ServicesService servicesService;
    @Autowired
    private PlaceService placeService;

    @Autowired
    private MenuService menuService;
    @Autowired
    private MenuItemService menuItemService;
    @Autowired
    private SectorService sectorService;


    private static Integer count = 0;
    @Override
    public UserDto login(String password) {
        /*
        Integer orderId = orderService.createOrder(1);

        OrderItemDto borsh = new OrderItemDto();
        borsh.setComment("Холодный, пересоленный.");
        borsh.setMenuItem(menuItemService.getMenuItemList(1, 1).get(0));

        OrderItemDto shurpa = new OrderItemDto();
        shurpa.setMenuItem(menuItemService.getMenuItemList(1, 1).get(1));

        orderService.addOrderItemsToOrder(orderId, borsh, shurpa);
        */

//        orderService.recountOrder(26);

        UserDto user = new UserDto();
        long before = System.currentTimeMillis();


        BigDecimal abc = new BigDecimal("0");
        for (int i = 0; i < 1000000; i++) {
            abc = abc.add(new BigDecimal(1500));
            if (abc.intValue() % 20 == 0) {
                Integer val = abc.intValue() + 15;
            } else {
                Integer val = abc.intValue() + 15;
            }
        }
        long after = System.currentTimeMillis();

        SimpleDateFormat sdf = new SimpleDateFormat("ss:SSS");
        user.setFirstName("Elapsed: " + sdf.format(new Date(after - before)) + "\nCount: " + count++);



        return user;//userService.getUserByPassword(password);
    }
}